package com.burgeon.backend.EnterpriseWeChat.controller;

import com.burgeon.backend.EnterpriseWeChat.entity.DIM;
import com.burgeon.backend.EnterpriseWeChat.entity.DimDef;
import com.burgeon.backend.EnterpriseWeChat.entity.Product;
import com.burgeon.backend.EnterpriseWeChat.entity.ProductItem;
import com.burgeon.backend.EnterpriseWeChat.service.EWBrandService;
import com.burgeon.backend.stsutil.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;

/**
 * 品牌异业
 */
@RestController
@CrossOrigin
@RequestMapping("ewapp/brand")
public class EWBrandController extends EWBaseController {
    @Autowired
    private EWBrandService ewBrandService;

    /**
     * 云仓库存
     * @param token
     * @param dimId1
     * @param dimId2
     * @param dimId3
     * @param dimId4
     * @return
     */
    @RequestMapping("getYuncangInventory")
    public ResponseResult<ArrayList<Product>> getYuncangInventory(String token, String dimId1, String dimId2,
                                                                  String dimId3, String dimId4,String dimId5,String dimId6, int page){
        ArrayList<Product> data = ewBrandService.getYuncangInventory(token, dimId1, dimId2, dimId3, dimId4,
                                                                     dimId5,dimId6,page);
        return new ResponseResult<>(SUCCESS,data);
    }

    /**
     * 云仓推荐
     * @param token
     * @param dimId1
     * @param dimId2
     * @param dimId3
     * @param dimId4
     * @param timeSpan
     * @return
     */
    @RequestMapping("getYuncangHot")
    public ResponseResult<ArrayList<Product>> getYuncangHot(String token, String dimId1, String dimId2,
                                                            String dimId3, String dimId4, String dimId5,String dimId6,String timeSpan, int page){
        ArrayList<Product> data = ewBrandService.getYuncangHot(token, dimId1, dimId2, dimId3, dimId4,dimId5,dimId6,timeSpan,page);
        return new ResponseResult<>(SUCCESS,data);
    }

    /**
     * 购物车推荐
     * @param token
     * @return
     */
    @RequestMapping("getRecommandList")
    public ResponseResult<ArrayList<Product>> getRecommandList(String token, String contend, int page){
        ArrayList<Product> data = ewBrandService.getRecommandList(token,contend,page);
        return new ResponseResult<>(SUCCESS,data);
    }

    /**
     * 筛选条件的类别
     * @param token
     * @return
     */
    @RequestMapping("getDIMData")
    public ResponseResult<ArrayList<DIM>> getFilterData(String token){
        ArrayList<DIM> data = ewBrandService.getDIMData(token);
        return new ResponseResult<>(SUCCESS,data);
    }
    /**
     * 筛选条件
     * @param token
     * @param dimFlag
     * @return
     */
    @RequestMapping("getFilterData")
    public ResponseResult<ArrayList<DimDef>> getFilterData(String token, String dimFlag, int page){
        ArrayList<DimDef> data = ewBrandService.getFilterData(token,dimFlag,page);
        return new ResponseResult<>(SUCCESS,data);
    }

    /**
     * 搜素云仓库存
     * @param token
     * @param content
     * @return
     */
    @RequestMapping("findYuncangInventory")
    public ResponseResult<ArrayList<Product>> findYuncangInventory(String token, String content, int page){
        ArrayList<Product> data = ewBrandService.FindYuncangInventory(token, content,page);
        return new ResponseResult<>(SUCCESS,data);
    }

    /**
     * 店仓库存
     * @param token
     * @param productName
     * @param longitude
     * @param latitude
     * @return
     */
    @RequestMapping("getProductInventory")
    public ResponseResult<HashMap> getProductInventory(String token, String productName, String longitude, String latitude){
        HashMap data = ewBrandService.getProductInventory(token, productName, longitude, latitude);
        return new ResponseResult<>(SUCCESS,data);
    }

    /**
     * 根据款号获取店仓的库存信息，颜色尺寸
     * @param token
     * @param productName
     * @param storeId
     * @return
     */
    @RequestMapping("getProductItems")
    public ResponseResult<ArrayList<ProductItem>> getProductItems(String token, String productName, String storeId){
        ArrayList<ProductItem> data = ewBrandService.getStoreInventory(token, productName, storeId);
        return new ResponseResult<>(SUCCESS,data);
    }


//    @RequestMapping("file")
//    public ResponseResult<MultipartFile> getProductInventory(String url) {
//        File file = ImageUrl.getFile(url);
////        File file = new File(filePath);
//        InputStream inputStream = null;
//        MultipartFile multipartFile = null;
//        try {
//            inputStream = new FileInputStream(file);
//            //借助的工具同样引入spring-mock包，pom文件在上边有
//            multipartFile= new MockMultipartFile(file.getName(), inputStream);
//        } catch (FileNotFoundException e) {
//            e.printStackTrace();
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
//
//
//        return new ResponseResult<>(SUCCESS,multipartFile);
//    }


}
